
<?php
require 'Controller.php ';
require 'Admin/Model/CartoonModel.php';
class CartoonController extends Controller{
	function __Construct(){
		parent::__Construct();
	
	}
	function listcartoons(){
		
		$model = new CartoonModel();
		$data = $model->getCartoonList();
		$this->assign('cartoons',$data);
		$this->display(); 
		//return $data;

	}
function delcartoon(){
			$cid=$_GET['cid'];//根据cid查找要删除的动漫
			$model=new CartoonModel();
			$result=$model->delCartoon($cid);
			if($result){
				echo "删除成功!3秒后跳转回动漫列表页";
				header("refresh:3;url='admin.php?c=cartoon&m=listcartoons'");//隔3秒跳回

			}
			else{
				echo "删除失败!";
				echo "<a href='admin.php?c=cartoon&m=listcartoons'>返回动漫列表</a>";
				
			}
		}
function regcartoon(){
	       $this->display();
}
function addcartoon(){
	$data=$_POST;
    $file=$_FILES;
    $model=new CartoonModel();
    $result=$model->addcartoon($data,$file);
    if ($result) {
    	echo "注册成功，3秒后返回动漫列表页。";
    	header("refresh:3;url='admin.php?c=cartoon&m=listcartoons'");
    }else{
    	echo "注册失败，3秒后返回动漫添加页重新添加。";
    	header("refresh:3;url='admin.php?c=cartoon&m=regcartoon'");
    }

}
function editcartoon(){
	$cid=$_GET['cid'];
	$model=new CartoonModel();
	$data=$model->editcartoon($cid);
    $this->assign('cartoon',$data);
    $this->display();

}
function updatecartoon(){
	$data=$_POST;
	$file=$_FILES;
	$model=new CartoonModel();
	$result=$model->updatecartoon($data,$file);
	if($result){
		echo "修改成功，3秒后返回动漫列表页。";
    	header("refresh:3;url='admin.php?c=cartoon&m=listcartoons'");
    }else{
    	echo "修改失败!";
    	echo "<a href='admin.php?c=cartoon&m=listcartoons'>";
    }
}
function searchcartoon(){
	    $cartoonname=$_POST;
	    $model = new CartoonModel();
		$data = $model->searchcartoon($cartoonname);
		$this->assign('cartoon',$data);
		$this->display(); 


}







}
?>
